package com.thread.threadpool;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author: may
 * @date: 2021年04月15日 20:11
 */
public class TestFutureTask {
    public static void main(String[] args) {
        try {
            FutureTask<String> ft = new FutureTask(() -> {
                System.out.println("i am futuretask");
                return "FutureTask";
            });
            new Thread(ft).start();
            System.out.println(ft.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
